From 7ed3bd8b9c501c3747c8b5577fc9c2ffd9913aa1 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Tue, 27 May 2014 22:06:38 -0700 Subject: [PATCH] Remove unnecessary BasicTerminal --- src/cargo/core/shell.rs | 71 ++++++----------------------------------- 1 file changed, 9 insertions(+), 62 deletions(-) diff --git a/src/cargo/core/shell.rs b/src/cargo/core/shell.rs index 7bcdbddd6..d6e112569 100644 --- a/src/cargo/core/shell.rs +++ b/src/cargo/core/shell.rs @@ -11,7 +11,7 @@ pub struct ShellConfig { } enum AdequateTerminal { - NoColor(BasicTerminal), + NoColor(T), Color(Box>) } @@ -26,7 +26,7 @@ impl Shell { let term: Option> = Terminal::new(out); term.map(|t| Shell { terminal: Color(box t as Box>), config: config }) } else { - Some(Shell { terminal: NoColor(BasicTerminal { writer: out }), config: config }) + Some(Shell { terminal: NoColor(out), config: config }) } } @@ -56,35 +56,35 @@ impl Terminal for Shell { fn fg(&mut self, color: color::Color) -> IoResult { match self.terminal { Color(ref mut c) => c.fg(color), - NoColor(ref mut n) => n.fg(color) + NoColor(_) => Ok(false) } } fn bg(&mut self, color: color::Color) -> IoResult { match self.terminal { Color(ref mut c) => c.bg(color), - NoColor(ref mut n) => n.bg(color) + NoColor(_) => Ok(false) } } fn attr(&mut self, attr: Attr) -> IoResult { match self.terminal { Color(ref mut c) => c.attr(attr), - NoColor(ref mut n) => n.attr(attr) + NoColor(_) => Ok(false) } } fn supports_attr(&self, attr: Attr) -> bool { match self.terminal { Color(ref c) => c.supports_attr(attr), - NoColor(ref n) => n.supports_attr(attr) + NoColor(_) => false } } fn reset(&mut self) -> IoResult<()> { match self.terminal { Color(ref mut c) => c.reset(), - NoColor(ref mut n) => n.reset() + NoColor(_) => Ok(()) } } @@ -95,14 +95,14 @@ impl Terminal for Shell { fn get_ref<'a>(&'a self) -> &'a T { match self.terminal { Color(ref c) => c.get_ref(), - NoColor(ref n) => n.get_ref() + NoColor(ref w) => w } } fn get_mut<'a>(&'a mut self) -> &'a mut T { match self.terminal { Color(ref mut c) => c.get_mut(), - NoColor(ref mut n) => n.get_mut() + NoColor(ref mut w) => w } } } @@ -122,56 +122,3 @@ impl Writer for Shell { } } } - -pub struct BasicTerminal { - writer: T -} - -impl Terminal for BasicTerminal { - fn new(out: T) -> Option> { - Some(BasicTerminal { writer: out }) - } - - fn fg(&mut self, _: Color) -> IoResult { - Ok(false) - } - - fn bg(&mut self, _: Color) -> IoResult { - Ok(false) - } - - fn attr(&mut self, _: Attr) -> IoResult { - Ok(false) - } - - fn supports_attr(&self, _: Attr) -> bool { - false - } - - fn reset(&mut self) -> IoResult<()> { - Ok(()) - } - - fn unwrap(self) -> T { - self.writer - } - - fn get_ref<'a>(&'a self) -> &'a T { - &self.writer - } - - fn get_mut<'a>(&'a mut self) -> &'a mut T { - &mut self.writer - } -} - -impl Writer for BasicTerminal { - fn write(&mut self, buf: &[u8]) -> IoResult<()> { - self.writer.write(buf) - } - - fn flush(&mut self) -> IoResult<()> { - self.writer.flush() - } -} - -- 2.30.2